a11y/entry: Fix text coords not adjusted for alloc
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 5 Oct 2017 15:49:00 +0000 (15:49 +0000)
committerDaniel Boles <dboles.src@gmail.com>
Sun, 15 Oct 2017 11:37:44 +0000 (12:37 +0100)
What is missing is the "allocation" part of x/y coordinates. Since
gtk_entry_realize doesn't call gtk_widget_set_window(priv->text_area),
the coordinates returned by gdk_window_get_origin don't include it.

This patch fixes this.

https://bugzilla.gnome.org/show_bug.cgi?id=784509

gtk/a11y/gtkentryaccessible.c

index abbaef8e9e2c16607e48fc03a8d4892a7ccde0cd..9519b091c5d637a2c4fdec2b5633221fc9d33b8b 100644 (file)
@@ -971,11 +971,14 @@ gtk_entry_accessible_get_character_extents (AtkText      *text,
   pango_layout_index_to_pos (gtk_entry_get_layout (entry), index, &char_rect);
   pango_extents_to_pixels (&char_rect, NULL);
 
+  GtkAllocation allocation;
+  gtk_widget_get_allocation (widget, &allocation);
+
   window = gtk_widget_get_window (widget);
   gdk_window_get_origin (window, &x_window, &y_window);
 
-  *x = x_window + x_layout + char_rect.x;
-  *y = y_window + y_layout + char_rect.y;
+  *x = x_window + allocation.x + x_layout + char_rect.x;
+  *y = y_window + allocation.y + y_layout + char_rect.y;
   *width = char_rect.width;
   *height = char_rect.height;